package com.lzh.chatnote.chat.dao;

import com.lzh.chatnote.chat.domain.entity.Contact;
import com.lzh.chatnote.chat.domain.vo.response.contact.ChatRoomResp;
import com.lzh.chatnote.chat.mapper.ContactMapper;
import com.lzh.chatnote.chat.service.ContactService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzh.chatnote.common.domian.vo.request.CursorPageBaseReq;
import com.lzh.chatnote.common.domian.vo.response.CursorPageBaseResp;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

/**
 * <p>
 * 会话列表,联系人列表 服务实现类
 * </p>
 *
 * @author lzh
 * @since 2025-09-25
 */
@Service
public class ContactDao extends ServiceImpl<ContactMapper, Contact> {
    public Contact queryUserLastMsgId(Long currentUserId, Long roomId) {
        return lambdaQuery().eq(Contact::getUid, currentUserId)
                .eq(Contact::getRoomId, roomId)
                .oneOpt()
                .orElse(null)
                ;
    }

    public void refreshLastMsgIdOrSave(Long roomId, Long msgId, List<Long> uids) {
        this.baseMapper.refreshLastMsgIdOrSave(roomId, msgId, uids);
    }
}
